#多线程
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys

class Main(QWidget):
    def __init__(self,parent=None):
        super(Main,self).__init__(parent)
        self.thread=MyThread()
        self.thread.setFlags("th1")
        self.thread.sinout.connect(self.outtext)
        self.thread.setval(10)
    def outtext(self,text):
        print(text)

class MyThread(QThread):
    sinout=pyqtSignal(str)
    def __init__(self,parent=None):
        super(MyThread,self).__init__(parent)
        self.flags=None
    def setFlags(self,text):
        self.flags=text
    def setval(self,val):
        self.times=int(val)
        self.start()

    def run(self):
        while self.times>0 and self.flags:
            self.sinout.emit(self.flags+"--"+str(self.times))
            self.times-=1


if __name__ == '__main__':
    app=QApplication(sys.argv)
    main=Main()
    main.show()
    sys.exit(app.exec_())